package com.hyh.ui.base;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.hyh.data.PlatModule;
import com.hyh.util.TUtil;
import com.platform.GosSession;

import butterknife.ButterKnife;

/**
 * Created by Administrator on 2019/1/26.
 */

public abstract class BaseActivity<T extends BasePresenter> extends AppCompatActivity {

    public T mPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayout());
        mPresenter = TUtil.getT(this,0);
        if(mPresenter!=null){
            mPresenter.attachView(this,this);
        }
        ButterKnife.bind(this);
        getIntentExtras(getIntent());
        initDataAndEvent();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if(mPresenter!=null){
            mPresenter.detachView();
            mPresenter = null;
        }
    }

    public abstract int getLayout();
    public abstract void getIntentExtras(Intent intent);
    public abstract void initDataAndEvent();

}
